package com.gg.registration.rabbitmq.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Author：  chenjunjia
 * Date：    2022/4/25 16:45
 * WeChat：  China_JoJo_
 */
@Service
public class RabbitService {

    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送至消息队列
     * @param exchange 交换机
     * @param routingKey 路由键
     * @param message 消息对象
     * @return
     */
    public boolean sendMessage(String exchange, String routingKey, Object message) {
        rabbitTemplate.convertAndSend(exchange,routingKey,message);
        return true;
    }
}
